
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 09/25/2013 13:09:32
-- Generated from EDMX file: C:\tfs2012\CloudFranceTriple\Captain\CloudFranceTriple\CloudFranceTriple.Models\Entities.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [cloudfrAboq2RsDM];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_AccountSetAccountingEntrySet]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[AccountingEntrySet] DROP CONSTRAINT [FK_AccountSetAccountingEntrySet];
GO
IF OBJECT_ID(N'[dbo].[FK_Bf3RankSmiliesSetBf3PlayerPropertySet]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Bf3PlayerPropertySet] DROP CONSTRAINT [FK_Bf3RankSmiliesSetBf3PlayerPropertySet];
GO
IF OBJECT_ID(N'[dbo].[FK_EventCategoryEvent]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EventSet] DROP CONSTRAINT [FK_EventCategoryEvent];
GO
IF OBJECT_ID(N'[dbo].[FK_ForumCategoryForumTopic]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ForumTopicSet] DROP CONSTRAINT [FK_ForumCategoryForumTopic];
GO
IF OBJECT_ID(N'[dbo].[FK_ForumForumCategory]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ForumCategorySet] DROP CONSTRAINT [FK_ForumForumCategory];
GO
IF OBJECT_ID(N'[dbo].[FK_ForumPostForumPostRead]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ForumPostReadSet] DROP CONSTRAINT [FK_ForumPostForumPostRead];
GO
IF OBJECT_ID(N'[dbo].[FK_ForumSetForumSecurity]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ForumSecuritySet] DROP CONSTRAINT [FK_ForumSetForumSecurity];
GO
IF OBJECT_ID(N'[dbo].[FK_ForumTopicForumPost]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ForumPostSet] DROP CONSTRAINT [FK_ForumTopicForumPost];
GO
IF OBJECT_ID(N'[dbo].[FK_ForumTopicPoll]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PollSet] DROP CONSTRAINT [FK_ForumTopicPoll];
GO
IF OBJECT_ID(N'[dbo].[FK_GameGameServer]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[GameServerSet] DROP CONSTRAINT [FK_GameGameServer];
GO
IF OBJECT_ID(N'[dbo].[FK_GameGroupSetGameSet]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[GameSet] DROP CONSTRAINT [FK_GameGroupSetGameSet];
GO
IF OBJECT_ID(N'[dbo].[FK_GamePlayerOnGame]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PlayerOnGameSet] DROP CONSTRAINT [FK_GamePlayerOnGame];
GO
IF OBJECT_ID(N'[dbo].[FK_LaBaffGameServer]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[GameServerSet] DROP CONSTRAINT [FK_LaBaffGameServer];
GO
IF OBJECT_ID(N'[dbo].[FK_LaBaffLaBaffGuildMaster]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[LaBaffGuildMasterSet] DROP CONSTRAINT [FK_LaBaffLaBaffGuildMaster];
GO
IF OBJECT_ID(N'[dbo].[FK_LaBaffLaBaffMember]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[LaBaffMemberSet] DROP CONSTRAINT [FK_LaBaffLaBaffMember];
GO
IF OBJECT_ID(N'[dbo].[FK_PlayerOnGameBf3PlayerProperty]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Bf3PlayerPropertySet] DROP CONSTRAINT [FK_PlayerOnGameBf3PlayerProperty];
GO
IF OBJECT_ID(N'[dbo].[FK_PollAnswerPollUser]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PollUserSet] DROP CONSTRAINT [FK_PollAnswerPollUser];
GO
IF OBJECT_ID(N'[dbo].[FK_PollPollAnswer]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PollAnswerSet] DROP CONSTRAINT [FK_PollPollAnswer];
GO
IF OBJECT_ID(N'[dbo].[FK_PrivateMessageBoxPrivateMessageRead]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PrivateMessageReadSet] DROP CONSTRAINT [FK_PrivateMessageBoxPrivateMessageRead];
GO
IF OBJECT_ID(N'[dbo].[FK_PublisherGame]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[GameSet] DROP CONSTRAINT [FK_PublisherGame];
GO
IF OBJECT_ID(N'[dbo].[fk_RoleId]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[webpages_UsersInRoles] DROP CONSTRAINT [fk_RoleId];
GO
IF OBJECT_ID(N'[dbo].[fk_UserId]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[webpages_UsersInRoles] DROP CONSTRAINT [fk_UserId];
GO
IF OBJECT_ID(N'[dbo].[FK_VeteranStatusVeteranWall]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[VeteranWall] DROP CONSTRAINT [FK_VeteranStatusVeteranWall];
GO
IF OBJECT_ID(N'[dbo].[FK_VeteranWallPeriodVeteranWall]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[VeteranWall] DROP CONSTRAINT [FK_VeteranWallPeriodVeteranWall];
GO
IF OBJECT_ID(N'[dbo].[FK_VeteranWallPeriodVeteranWall1]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[VeteranWall] DROP CONSTRAINT [FK_VeteranWallPeriodVeteranWall1];
GO
IF OBJECT_ID(N'[dbo].[FK_webpages_RolesForumSecurity]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ForumSecuritySet] DROP CONSTRAINT [FK_webpages_RolesForumSecurity];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[AccountingEntrySet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[AccountingEntrySet];
GO
IF OBJECT_ID(N'[dbo].[AccountSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[AccountSet];
GO
IF OBJECT_ID(N'[dbo].[ApplicationSettingSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ApplicationSettingSet];
GO
IF OBJECT_ID(N'[dbo].[Bf3PlayerPropertySet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Bf3PlayerPropertySet];
GO
IF OBJECT_ID(N'[dbo].[Bf3RankSmiliesSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Bf3RankSmiliesSet];
GO
IF OBJECT_ID(N'[dbo].[EventCategorySet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EventCategorySet];
GO
IF OBJECT_ID(N'[dbo].[EventSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EventSet];
GO
IF OBJECT_ID(N'[dbo].[ForumAnnonceSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumAnnonceSet];
GO
IF OBJECT_ID(N'[dbo].[ForumCategorySet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumCategorySet];
GO
IF OBJECT_ID(N'[dbo].[ForumPostReadSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumPostReadSet];
GO
IF OBJECT_ID(N'[dbo].[ForumPostSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumPostSet];
GO
IF OBJECT_ID(N'[dbo].[ForumSecuritySet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumSecuritySet];
GO
IF OBJECT_ID(N'[dbo].[ForumSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumSet];
GO
IF OBJECT_ID(N'[dbo].[ForumSmilieSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumSmilieSet];
GO
IF OBJECT_ID(N'[dbo].[ForumTopicSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumTopicSet];
GO
IF OBJECT_ID(N'[dbo].[GameGroupSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[GameGroupSet];
GO
IF OBJECT_ID(N'[dbo].[GameServerSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[GameServerSet];
GO
IF OBJECT_ID(N'[dbo].[GameSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[GameSet];
GO
IF OBJECT_ID(N'[dbo].[LaBaffGuildMasterSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LaBaffGuildMasterSet];
GO
IF OBJECT_ID(N'[dbo].[LaBaffMemberSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LaBaffMemberSet];
GO
IF OBJECT_ID(N'[dbo].[LaBaffSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LaBaffSet];
GO
IF OBJECT_ID(N'[dbo].[NewsSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[NewsSet];
GO
IF OBJECT_ID(N'[dbo].[PlayerOnGameSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PlayerOnGameSet];
GO
IF OBJECT_ID(N'[dbo].[PollAnswerSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PollAnswerSet];
GO
IF OBJECT_ID(N'[dbo].[PollSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PollSet];
GO
IF OBJECT_ID(N'[dbo].[PollUserSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PollUserSet];
GO
IF OBJECT_ID(N'[dbo].[PrivateMessageBoxSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivateMessageBoxSet];
GO
IF OBJECT_ID(N'[dbo].[PrivateMessageReadSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivateMessageReadSet];
GO
IF OBJECT_ID(N'[dbo].[PublisherSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PublisherSet];
GO
IF OBJECT_ID(N'[dbo].[ShoutBoxSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ShoutBoxSet];
GO
IF OBJECT_ID(N'[dbo].[SmilieSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[SmilieSet];
GO
IF OBJECT_ID(N'[dbo].[UserProfile]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UserProfile];
GO
IF OBJECT_ID(N'[dbo].[VeteranStatus]', 'U') IS NOT NULL
    DROP TABLE [dbo].[VeteranStatus];
GO
IF OBJECT_ID(N'[dbo].[VeteranWall]', 'U') IS NOT NULL
    DROP TABLE [dbo].[VeteranWall];
GO
IF OBJECT_ID(N'[dbo].[VeteranWallPeriod]', 'U') IS NOT NULL
    DROP TABLE [dbo].[VeteranWallPeriod];
GO
IF OBJECT_ID(N'[dbo].[webpages_Membership]', 'U') IS NOT NULL
    DROP TABLE [dbo].[webpages_Membership];
GO
IF OBJECT_ID(N'[dbo].[webpages_OAuthMembership]', 'U') IS NOT NULL
    DROP TABLE [dbo].[webpages_OAuthMembership];
GO
IF OBJECT_ID(N'[dbo].[webpages_Roles]', 'U') IS NOT NULL
    DROP TABLE [dbo].[webpages_Roles];
GO
IF OBJECT_ID(N'[dbo].[webpages_UsersInRoles]', 'U') IS NOT NULL
    DROP TABLE [dbo].[webpages_UsersInRoles];
GO
IF OBJECT_ID(N'[cloudfrAboq2RsDMModelStoreContainer].[vw_ForumLastTopic]', 'U') IS NOT NULL
    DROP TABLE [cloudfrAboq2RsDMModelStoreContainer].[vw_ForumLastTopic];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'AccountingEntrySet'
CREATE TABLE [dbo].[AccountingEntrySet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Actor] nvarchar(128)  NOT NULL,
    [Label] nvarchar(128)  NOT NULL,
    [PurchaseDate] datetime  NOT NULL,
    [BankDate] datetime  NULL,
    [DebitAmount] decimal(17,2)  NULL,
    [CreditAmount] decimal(17,2)  NULL,
    [Author] nvarchar(56)  NOT NULL,
    [AuthorIp] nvarchar(15)  NOT NULL,
    [AccountSet_Id] int  NOT NULL
);
GO

-- Creating table 'AccountSet'
CREATE TABLE [dbo].[AccountSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Label] nvarchar(128)  NOT NULL
);
GO

-- Creating table 'ApplicationSettingSet'
CREATE TABLE [dbo].[ApplicationSettingSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(128)  NOT NULL,
    [Value] nvarchar(128)  NOT NULL
);
GO

-- Creating table 'Bf3PlayerPropertySet'
CREATE TABLE [dbo].[Bf3PlayerPropertySet] (
    [GameId] int  NOT NULL,
    [UserId] int  NOT NULL,
    [TimePlayedToBecomeColonel] nvarchar(max)  NOT NULL,
    [DisplayOrderHallOfFamousPlayer] nvarchar(max)  NOT NULL,
    [BattlelogUrlProfile] nvarchar(max)  NOT NULL,
    [Bf3RankSmiliesSet_Id] int  NOT NULL
);
GO

-- Creating table 'Bf3RankSmiliesSet'
CREATE TABLE [dbo].[Bf3RankSmiliesSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Rank] smallint  NOT NULL,
    [ImageUrl] nvarchar(64)  NOT NULL
);
GO

-- Creating table 'EventCategorySet'
CREATE TABLE [dbo].[EventCategorySet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [LabelEventCategory] nvarchar(128)  NOT NULL,
    [ColorEventCategory] nchar(6)  NOT NULL,
    [BackColorEventCategory] nchar(6)  NOT NULL,
    [OrderEventCategory] int  NOT NULL
);
GO

-- Creating table 'EventSet'
CREATE TABLE [dbo].[EventSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [AuthorEvent] nvarchar(256)  NOT NULL,
    [TitleEvent] nvarchar(128)  NOT NULL,
    [DateStartEvent] datetime  NOT NULL,
    [DateEndEvent] datetime  NOT NULL,
    [AllDayEvent] bit  NOT NULL,
    [DescriptionEvent] nvarchar(max)  NULL,
    [EventCategory_Id] int  NOT NULL
);
GO

-- Creating table 'ForumAnnonceSet'
CREATE TABLE [dbo].[ForumAnnonceSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Text] nvarchar(max)  NOT NULL,
    [ShowOnHeader] bit  NOT NULL,
    [ShowOnPortail] bit  NOT NULL,
    [ShowOnForum] bit  NOT NULL,
    [ShowOnTopic] bit  NOT NULL,
    [ShowOnPost] bit  NOT NULL,
    [DateBegin] datetime  NOT NULL,
    [DateEnd] datetime  NULL,
    [Order] int  NOT NULL
);
GO

-- Creating table 'ForumCategorySet'
CREATE TABLE [dbo].[ForumCategorySet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [LabelForumCategory] nvarchar(128)  NOT NULL,
    [DescriptionForumCategory] nvarchar(max)  NULL,
    [OrderForumCategory] int  NOT NULL,
    [NumberOfTopic] int  NOT NULL,
    [NumberOfMessage] int  NOT NULL,
    [LastPostId] int  NULL,
    [LastPostCreationDate] datetime  NULL,
    [LastPostAuthor] nvarchar(128)  NULL,
    [LastPostTopicId] int  NULL,
    [Forum_Id] int  NOT NULL
);
GO

-- Creating table 'ForumPostReadSet'
CREATE TABLE [dbo].[ForumPostReadSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UserId] int  NOT NULL,
    [ForumPost_Id] int  NOT NULL
);
GO

-- Creating table 'ForumPostSet'
CREATE TABLE [dbo].[ForumPostSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [PostMessage_Message] nvarchar(max)  NOT NULL,
    [PostMessage_CreationDate] datetime  NOT NULL,
    [PostMessage_Author] nvarchar(56)  NOT NULL,
    [PostMessage_AuthorAdressIp] nvarchar(15)  NOT NULL,
    [ForumTopic_Id] int  NOT NULL
);
GO

-- Creating table 'ForumSecuritySet'
CREATE TABLE [dbo].[ForumSecuritySet] (
    [RightLevel] smallint  NOT NULL,
    [ForumSet_Id] int  NOT NULL,
    [webpages_Roles_RoleId] int  NOT NULL
);
GO

-- Creating table 'ForumSet'
CREATE TABLE [dbo].[ForumSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [LabelForum] nvarchar(128)  NOT NULL,
    [OrderForum] int  NOT NULL
);
GO

-- Creating table 'ForumSmilieSet'
CREATE TABLE [dbo].[ForumSmilieSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [CodeSmilie] nvarchar(16)  NOT NULL,
    [ImageFileName] nvarchar(64)  NOT NULL,
    [IsUsedForComposed] bit  NOT NULL
);
GO

-- Creating table 'ForumTopicSet'
CREATE TABLE [dbo].[ForumTopicSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [LabelForumTopic] nvarchar(128)  NOT NULL,
    [AuthorForumTopic] nvarchar(56)  NOT NULL,
    [NumberHasBeenSeenForumTopic] int  NOT NULL,
    [OrderForumTopic] int  NOT NULL,
    [IsUnlocked] bit  NOT NULL,
    [CreationDateForumTopic] datetime  NOT NULL,
    [ForumCategory_Id] int  NOT NULL
);
GO

-- Creating table 'GameGroupSet'
CREATE TABLE [dbo].[GameGroupSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Label] nvarchar(128)  NOT NULL,
    [Order] int  NOT NULL
);
GO

-- Creating table 'GameServerSet'
CREATE TABLE [dbo].[GameServerSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [AddressGameServer] nvarchar(max)  NOT NULL,
    [PasswordGameServer] nvarchar(max)  NOT NULL,
    [Game_Id] int  NOT NULL,
    [LaBaff_Id] int  NOT NULL
);
GO

-- Creating table 'GameSet'
CREATE TABLE [dbo].[GameSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [NameGame] nvarchar(max)  NOT NULL,
    [NicknameGame] nvarchar(max)  NOT NULL,
    [OfficialWebSiteGame] nvarchar(max)  NOT NULL,
    [LogoUrlGame] nvarchar(max)  NOT NULL,
    [DescriptionGame] nvarchar(max)  NULL,
    [Publisher_Id] int  NOT NULL,
    [OrderGame] int  NOT NULL,
    [GameGroupSet_Id] int  NOT NULL
);
GO

-- Creating table 'LaBaffGuildMasterSet'
CREATE TABLE [dbo].[LaBaffGuildMasterSet] (
    [TeamId] int  NOT NULL,
    [UserId] int  NOT NULL
);
GO

-- Creating table 'LaBaffMemberSet'
CREATE TABLE [dbo].[LaBaffMemberSet] (
    [TeamId] int  NOT NULL,
    [UserId] int  NOT NULL
);
GO

-- Creating table 'LaBaffSet'
CREATE TABLE [dbo].[LaBaffSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(128)  NOT NULL,
    [Tag] nvarchar(16)  NULL,
    [IsPublicVisible] bit  NOT NULL,
    [Description] nvarchar(max)  NULL,
    [Website] nvarchar(128)  NULL,
    [TeamspeakIp] nvarchar(128)  NULL,
    [BannerImageUrl] nvarchar(512)  NULL,
    [Order] int  NOT NULL,
    [Bf3PlatoonUrl] nvarchar(512)  NULL,
    [Bf4PlatoonUrl] nvarchar(512)  NULL
);
GO

-- Creating table 'NewsSet'
CREATE TABLE [dbo].[NewsSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Text] nvarchar(max)  NOT NULL,
    [DateBegin] datetime  NOT NULL,
    [DateEnd] datetime  NULL,
    [Order] int  NOT NULL,
    [Title] nvarchar(128)  NOT NULL,
    [Author] nvarchar(56)  NOT NULL,
    [AuthorIp] nvarchar(15)  NOT NULL
);
GO

-- Creating table 'PlayerOnGameSet'
CREATE TABLE [dbo].[PlayerOnGameSet] (
    [GameId] int  NOT NULL,
    [UserId] int  NOT NULL,
    [PlayerNickName] nvarchar(max)  NOT NULL,
    [Game_Id] int  NOT NULL
);
GO

-- Creating table 'PollAnswerSet'
CREATE TABLE [dbo].[PollAnswerSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [LabelPollAnwser] nvarchar(128)  NOT NULL,
    [NumberVotePollAnswer] int  NOT NULL,
    [Poll_Id] int  NOT NULL
);
GO

-- Creating table 'PollSet'
CREATE TABLE [dbo].[PollSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [LabelPoll] nvarchar(128)  NOT NULL,
    [DescriptionPoll] nvarchar(max)  NULL,
    [CreationDatePoll] datetime  NOT NULL,
    [OrderPoll] int  NOT NULL,
    [DurationInDays] int  NOT NULL,
    [ForumTopic_Id] int  NULL,
    [IsPublicPollResult] bit  NOT NULL,
    [IsMemberOnlyPoll] bit  NOT NULL,
    [IsRecruitPoll] bit  NOT NULL
);
GO

-- Creating table 'PollUserSet'
CREATE TABLE [dbo].[PollUserSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UserId] int  NOT NULL,
    [PollAnswer_Id] int  NOT NULL
);
GO

-- Creating table 'PrivateMessageBoxSet'
CREATE TABLE [dbo].[PrivateMessageBoxSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [FromPrivateMessage] int  NOT NULL,
    [ToPrivateMessage] int  NOT NULL,
    [MessageBody_Label] nvarchar(128)  NULL,
    [MessageBody_Message] nvarchar(max)  NOT NULL,
    [MessageBody_CreationDate] datetime  NOT NULL,
    [MessageBody_Author] nvarchar(56)  NOT NULL,
    [MessageBody_AuthorAdressIp] nvarchar(15)  NOT NULL,
    [ParentId] int  NULL
);
GO

-- Creating table 'PrivateMessageReadSet'
CREATE TABLE [dbo].[PrivateMessageReadSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UserId] int  NOT NULL,
    [PrivateMessageBox_Id] int  NOT NULL
);
GO

-- Creating table 'PublisherSet'
CREATE TABLE [dbo].[PublisherSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [NamePublisher] nvarchar(max)  NOT NULL,
    [OfficialWebSitePublisher] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'ShoutBoxSet'
CREATE TABLE [dbo].[ShoutBoxSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UserNameAuthorShoutBox] nvarchar(256)  NOT NULL,
    [MessageShoutBox] nvarchar(1024)  NOT NULL,
    [CreationDateShoutBox] datetime  NOT NULL
);
GO

-- Creating table 'SmilieSet'
CREATE TABLE [dbo].[SmilieSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [CodeSmilie] nvarchar(16)  NOT NULL,
    [ImageFileName] nvarchar(64)  NOT NULL
);
GO

-- Creating table 'UserProfile'
CREATE TABLE [dbo].[UserProfile] (
    [UserId] int IDENTITY(1,1) NOT NULL,
    [UserName] nvarchar(56)  NOT NULL,
    [Email] nvarchar(128)  NOT NULL,
    [Culture] nvarchar(10)  NOT NULL,
    [Theming] nvarchar(64)  NOT NULL,
    [Birthday] datetime  NOT NULL,
    [ShowInBirthdayList] bit  NOT NULL,
    [UpperLabelSignature] nvarchar(128)  NULL,
    [ImageUrlSignature] nvarchar(256)  NULL,
    [NavigateUrlSignature] nvarchar(256)  NULL,
    [BottomLabelSignature] nvarchar(128)  NULL,
    [ForumMessagePostedCounter] int  NOT NULL,
    [Location] nvarchar(128)  NOT NULL,
    [InitialAddressIp] nvarchar(50)  NOT NULL,
    [LastAddressIp] nvarchar(15)  NOT NULL,
    [TimeZone] nvarchar(32)  NOT NULL,
    [gravatar] nvarchar(128)  NULL,
    [LastRequestDate] datetime  NOT NULL,
    [ShowInNonAdminList] bit  NOT NULL
);
GO

-- Creating table 'webpages_Membership'
CREATE TABLE [dbo].[webpages_Membership] (
    [UserId] int  NOT NULL,
    [CreateDate] datetime  NULL,
    [ConfirmationToken] nvarchar(128)  NULL,
    [IsConfirmed] bit  NULL,
    [LastPasswordFailureDate] datetime  NULL,
    [PasswordFailuresSinceLastSuccess] int  NOT NULL,
    [Password] nvarchar(128)  NOT NULL,
    [PasswordChangedDate] datetime  NULL,
    [PasswordSalt] nvarchar(128)  NOT NULL,
    [PasswordVerificationToken] nvarchar(128)  NULL,
    [PasswordVerificationTokenExpirationDate] datetime  NULL
);
GO

-- Creating table 'webpages_OAuthMembership'
CREATE TABLE [dbo].[webpages_OAuthMembership] (
    [Provider] nvarchar(30)  NOT NULL,
    [ProviderUserId] nvarchar(100)  NOT NULL,
    [UserId] int  NOT NULL
);
GO

-- Creating table 'webpages_Roles'
CREATE TABLE [dbo].[webpages_Roles] (
    [RoleId] int IDENTITY(1,1) NOT NULL,
    [RoleName] nvarchar(256)  NOT NULL
);
GO

-- Creating table 'VeteranStatus'
CREATE TABLE [dbo].[VeteranStatus] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Label] nvarchar(32)  NOT NULL
);
GO

-- Creating table 'VeteranWall'
CREATE TABLE [dbo].[VeteranWall] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Pseudo] nvarchar(56)  NOT NULL,
    [Email] nvarchar(128)  NULL,
    [Comment] nvarchar(max)  NOT NULL,
    [Author] nvarchar(56)  NOT NULL,
    [VeteranStatus_Id] int  NOT NULL,
    [VeteranWallPeriodBegin_Id] int  NOT NULL,
    [VeteranWallPeriodEnd_Id] int  NOT NULL
);
GO

-- Creating table 'VeteranWallPeriod'
CREATE TABLE [dbo].[VeteranWallPeriod] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [VeteranWallYearPeriod] int  NOT NULL,
    [VeteranWallMonthPeriod] int  NOT NULL
);
GO

-- Creating table 'vw_ForumLastTopic'
CREATE TABLE [dbo].[vw_ForumLastTopic] (
    [Id] int  NOT NULL,
    [Label] nvarchar(128)  NOT NULL,
    [Author] nvarchar(56)  NOT NULL,
    [NumberHasBeenSeen] int  NOT NULL,
    [IsUnlocked] bit  NOT NULL,
    [OrderForumTopic] int  NOT NULL,
    [CreationDateForumTopic] datetime  NOT NULL,
    [LastPostDate] datetime  NULL,
    [NumberOfPost] int  NULL,
    [LastPostId] int  NULL,
    [ForumCategoryId] int  NOT NULL,
    [ForumId] int  NOT NULL
);
GO

-- Creating table 'webpages_UsersInRoles'
CREATE TABLE [dbo].[webpages_UsersInRoles] (
    [webpages_Roles_RoleId] int  NOT NULL,
    [UserProfile_UserId] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'AccountingEntrySet'
ALTER TABLE [dbo].[AccountingEntrySet]
ADD CONSTRAINT [PK_AccountingEntrySet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'AccountSet'
ALTER TABLE [dbo].[AccountSet]
ADD CONSTRAINT [PK_AccountSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ApplicationSettingSet'
ALTER TABLE [dbo].[ApplicationSettingSet]
ADD CONSTRAINT [PK_ApplicationSettingSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [GameId], [UserId] in table 'Bf3PlayerPropertySet'
ALTER TABLE [dbo].[Bf3PlayerPropertySet]
ADD CONSTRAINT [PK_Bf3PlayerPropertySet]
    PRIMARY KEY CLUSTERED ([GameId], [UserId] ASC);
GO

-- Creating primary key on [Id] in table 'Bf3RankSmiliesSet'
ALTER TABLE [dbo].[Bf3RankSmiliesSet]
ADD CONSTRAINT [PK_Bf3RankSmiliesSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'EventCategorySet'
ALTER TABLE [dbo].[EventCategorySet]
ADD CONSTRAINT [PK_EventCategorySet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'EventSet'
ALTER TABLE [dbo].[EventSet]
ADD CONSTRAINT [PK_EventSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ForumAnnonceSet'
ALTER TABLE [dbo].[ForumAnnonceSet]
ADD CONSTRAINT [PK_ForumAnnonceSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ForumCategorySet'
ALTER TABLE [dbo].[ForumCategorySet]
ADD CONSTRAINT [PK_ForumCategorySet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ForumPostReadSet'
ALTER TABLE [dbo].[ForumPostReadSet]
ADD CONSTRAINT [PK_ForumPostReadSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ForumPostSet'
ALTER TABLE [dbo].[ForumPostSet]
ADD CONSTRAINT [PK_ForumPostSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [ForumSet_Id], [webpages_Roles_RoleId] in table 'ForumSecuritySet'
ALTER TABLE [dbo].[ForumSecuritySet]
ADD CONSTRAINT [PK_ForumSecuritySet]
    PRIMARY KEY CLUSTERED ([ForumSet_Id], [webpages_Roles_RoleId] ASC);
GO

-- Creating primary key on [Id] in table 'ForumSet'
ALTER TABLE [dbo].[ForumSet]
ADD CONSTRAINT [PK_ForumSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ForumSmilieSet'
ALTER TABLE [dbo].[ForumSmilieSet]
ADD CONSTRAINT [PK_ForumSmilieSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ForumTopicSet'
ALTER TABLE [dbo].[ForumTopicSet]
ADD CONSTRAINT [PK_ForumTopicSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'GameGroupSet'
ALTER TABLE [dbo].[GameGroupSet]
ADD CONSTRAINT [PK_GameGroupSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'GameServerSet'
ALTER TABLE [dbo].[GameServerSet]
ADD CONSTRAINT [PK_GameServerSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'GameSet'
ALTER TABLE [dbo].[GameSet]
ADD CONSTRAINT [PK_GameSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [TeamId], [UserId] in table 'LaBaffGuildMasterSet'
ALTER TABLE [dbo].[LaBaffGuildMasterSet]
ADD CONSTRAINT [PK_LaBaffGuildMasterSet]
    PRIMARY KEY CLUSTERED ([TeamId], [UserId] ASC);
GO

-- Creating primary key on [TeamId], [UserId] in table 'LaBaffMemberSet'
ALTER TABLE [dbo].[LaBaffMemberSet]
ADD CONSTRAINT [PK_LaBaffMemberSet]
    PRIMARY KEY CLUSTERED ([TeamId], [UserId] ASC);
GO

-- Creating primary key on [Id] in table 'LaBaffSet'
ALTER TABLE [dbo].[LaBaffSet]
ADD CONSTRAINT [PK_LaBaffSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'NewsSet'
ALTER TABLE [dbo].[NewsSet]
ADD CONSTRAINT [PK_NewsSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [GameId], [UserId] in table 'PlayerOnGameSet'
ALTER TABLE [dbo].[PlayerOnGameSet]
ADD CONSTRAINT [PK_PlayerOnGameSet]
    PRIMARY KEY CLUSTERED ([GameId], [UserId] ASC);
GO

-- Creating primary key on [Id] in table 'PollAnswerSet'
ALTER TABLE [dbo].[PollAnswerSet]
ADD CONSTRAINT [PK_PollAnswerSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PollSet'
ALTER TABLE [dbo].[PollSet]
ADD CONSTRAINT [PK_PollSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PollUserSet'
ALTER TABLE [dbo].[PollUserSet]
ADD CONSTRAINT [PK_PollUserSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PrivateMessageBoxSet'
ALTER TABLE [dbo].[PrivateMessageBoxSet]
ADD CONSTRAINT [PK_PrivateMessageBoxSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PrivateMessageReadSet'
ALTER TABLE [dbo].[PrivateMessageReadSet]
ADD CONSTRAINT [PK_PrivateMessageReadSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PublisherSet'
ALTER TABLE [dbo].[PublisherSet]
ADD CONSTRAINT [PK_PublisherSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ShoutBoxSet'
ALTER TABLE [dbo].[ShoutBoxSet]
ADD CONSTRAINT [PK_ShoutBoxSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'SmilieSet'
ALTER TABLE [dbo].[SmilieSet]
ADD CONSTRAINT [PK_SmilieSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [UserId] in table 'UserProfile'
ALTER TABLE [dbo].[UserProfile]
ADD CONSTRAINT [PK_UserProfile]
    PRIMARY KEY CLUSTERED ([UserId] ASC);
GO

-- Creating primary key on [UserId] in table 'webpages_Membership'
ALTER TABLE [dbo].[webpages_Membership]
ADD CONSTRAINT [PK_webpages_Membership]
    PRIMARY KEY CLUSTERED ([UserId] ASC);
GO

-- Creating primary key on [Provider], [ProviderUserId] in table 'webpages_OAuthMembership'
ALTER TABLE [dbo].[webpages_OAuthMembership]
ADD CONSTRAINT [PK_webpages_OAuthMembership]
    PRIMARY KEY CLUSTERED ([Provider], [ProviderUserId] ASC);
GO

-- Creating primary key on [RoleId] in table 'webpages_Roles'
ALTER TABLE [dbo].[webpages_Roles]
ADD CONSTRAINT [PK_webpages_Roles]
    PRIMARY KEY CLUSTERED ([RoleId] ASC);
GO

-- Creating primary key on [Id] in table 'VeteranStatus'
ALTER TABLE [dbo].[VeteranStatus]
ADD CONSTRAINT [PK_VeteranStatus]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'VeteranWall'
ALTER TABLE [dbo].[VeteranWall]
ADD CONSTRAINT [PK_VeteranWall]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'VeteranWallPeriod'
ALTER TABLE [dbo].[VeteranWallPeriod]
ADD CONSTRAINT [PK_VeteranWallPeriod]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id], [Label], [Author], [NumberHasBeenSeen], [IsUnlocked], [OrderForumTopic], [CreationDateForumTopic], [ForumCategoryId], [ForumId] in table 'vw_ForumLastTopic'
ALTER TABLE [dbo].[vw_ForumLastTopic]
ADD CONSTRAINT [PK_vw_ForumLastTopic]
    PRIMARY KEY CLUSTERED ([Id], [Label], [Author], [NumberHasBeenSeen], [IsUnlocked], [OrderForumTopic], [CreationDateForumTopic], [ForumCategoryId], [ForumId] ASC);
GO

-- Creating primary key on [webpages_Roles_RoleId], [UserProfile_UserId] in table 'webpages_UsersInRoles'
ALTER TABLE [dbo].[webpages_UsersInRoles]
ADD CONSTRAINT [PK_webpages_UsersInRoles]
    PRIMARY KEY NONCLUSTERED ([webpages_Roles_RoleId], [UserProfile_UserId] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [AccountSet_Id] in table 'AccountingEntrySet'
ALTER TABLE [dbo].[AccountingEntrySet]
ADD CONSTRAINT [FK_AccountSetAccountingEntrySet]
    FOREIGN KEY ([AccountSet_Id])
    REFERENCES [dbo].[AccountSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_AccountSetAccountingEntrySet'
CREATE INDEX [IX_FK_AccountSetAccountingEntrySet]
ON [dbo].[AccountingEntrySet]
    ([AccountSet_Id]);
GO

-- Creating foreign key on [Bf3RankSmiliesSet_Id] in table 'Bf3PlayerPropertySet'
ALTER TABLE [dbo].[Bf3PlayerPropertySet]
ADD CONSTRAINT [FK_Bf3RankSmiliesSetBf3PlayerPropertySet]
    FOREIGN KEY ([Bf3RankSmiliesSet_Id])
    REFERENCES [dbo].[Bf3RankSmiliesSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Bf3RankSmiliesSetBf3PlayerPropertySet'
CREATE INDEX [IX_FK_Bf3RankSmiliesSetBf3PlayerPropertySet]
ON [dbo].[Bf3PlayerPropertySet]
    ([Bf3RankSmiliesSet_Id]);
GO

-- Creating foreign key on [GameId], [UserId] in table 'Bf3PlayerPropertySet'
ALTER TABLE [dbo].[Bf3PlayerPropertySet]
ADD CONSTRAINT [FK_PlayerOnGameBf3PlayerProperty]
    FOREIGN KEY ([GameId], [UserId])
    REFERENCES [dbo].[PlayerOnGameSet]
        ([GameId], [UserId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [EventCategory_Id] in table 'EventSet'
ALTER TABLE [dbo].[EventSet]
ADD CONSTRAINT [FK_EventCategoryEvent]
    FOREIGN KEY ([EventCategory_Id])
    REFERENCES [dbo].[EventCategorySet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EventCategoryEvent'
CREATE INDEX [IX_FK_EventCategoryEvent]
ON [dbo].[EventSet]
    ([EventCategory_Id]);
GO

-- Creating foreign key on [ForumCategory_Id] in table 'ForumTopicSet'
ALTER TABLE [dbo].[ForumTopicSet]
ADD CONSTRAINT [FK_ForumCategoryForumTopic]
    FOREIGN KEY ([ForumCategory_Id])
    REFERENCES [dbo].[ForumCategorySet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ForumCategoryForumTopic'
CREATE INDEX [IX_FK_ForumCategoryForumTopic]
ON [dbo].[ForumTopicSet]
    ([ForumCategory_Id]);
GO

-- Creating foreign key on [Forum_Id] in table 'ForumCategorySet'
ALTER TABLE [dbo].[ForumCategorySet]
ADD CONSTRAINT [FK_ForumForumCategory]
    FOREIGN KEY ([Forum_Id])
    REFERENCES [dbo].[ForumSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ForumForumCategory'
CREATE INDEX [IX_FK_ForumForumCategory]
ON [dbo].[ForumCategorySet]
    ([Forum_Id]);
GO

-- Creating foreign key on [ForumPost_Id] in table 'ForumPostReadSet'
ALTER TABLE [dbo].[ForumPostReadSet]
ADD CONSTRAINT [FK_ForumPostForumPostRead]
    FOREIGN KEY ([ForumPost_Id])
    REFERENCES [dbo].[ForumPostSet]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ForumPostForumPostRead'
CREATE INDEX [IX_FK_ForumPostForumPostRead]
ON [dbo].[ForumPostReadSet]
    ([ForumPost_Id]);
GO

-- Creating foreign key on [ForumTopic_Id] in table 'ForumPostSet'
ALTER TABLE [dbo].[ForumPostSet]
ADD CONSTRAINT [FK_ForumTopicForumPost]
    FOREIGN KEY ([ForumTopic_Id])
    REFERENCES [dbo].[ForumTopicSet]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ForumTopicForumPost'
CREATE INDEX [IX_FK_ForumTopicForumPost]
ON [dbo].[ForumPostSet]
    ([ForumTopic_Id]);
GO

-- Creating foreign key on [ForumSet_Id] in table 'ForumSecuritySet'
ALTER TABLE [dbo].[ForumSecuritySet]
ADD CONSTRAINT [FK_ForumSetForumSecurity]
    FOREIGN KEY ([ForumSet_Id])
    REFERENCES [dbo].[ForumSet]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ForumTopic_Id] in table 'PollSet'
ALTER TABLE [dbo].[PollSet]
ADD CONSTRAINT [FK_ForumTopicPoll]
    FOREIGN KEY ([ForumTopic_Id])
    REFERENCES [dbo].[ForumTopicSet]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ForumTopicPoll'
CREATE INDEX [IX_FK_ForumTopicPoll]
ON [dbo].[PollSet]
    ([ForumTopic_Id]);
GO

-- Creating foreign key on [GameGroupSet_Id] in table 'GameSet'
ALTER TABLE [dbo].[GameSet]
ADD CONSTRAINT [FK_GameGroupSetGameSet]
    FOREIGN KEY ([GameGroupSet_Id])
    REFERENCES [dbo].[GameGroupSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GameGroupSetGameSet'
CREATE INDEX [IX_FK_GameGroupSetGameSet]
ON [dbo].[GameSet]
    ([GameGroupSet_Id]);
GO

-- Creating foreign key on [Game_Id] in table 'GameServerSet'
ALTER TABLE [dbo].[GameServerSet]
ADD CONSTRAINT [FK_GameGameServer]
    FOREIGN KEY ([Game_Id])
    REFERENCES [dbo].[GameSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GameGameServer'
CREATE INDEX [IX_FK_GameGameServer]
ON [dbo].[GameServerSet]
    ([Game_Id]);
GO

-- Creating foreign key on [LaBaff_Id] in table 'GameServerSet'
ALTER TABLE [dbo].[GameServerSet]
ADD CONSTRAINT [FK_LaBaffGameServer]
    FOREIGN KEY ([LaBaff_Id])
    REFERENCES [dbo].[LaBaffSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LaBaffGameServer'
CREATE INDEX [IX_FK_LaBaffGameServer]
ON [dbo].[GameServerSet]
    ([LaBaff_Id]);
GO

-- Creating foreign key on [Game_Id] in table 'PlayerOnGameSet'
ALTER TABLE [dbo].[PlayerOnGameSet]
ADD CONSTRAINT [FK_GamePlayerOnGame]
    FOREIGN KEY ([Game_Id])
    REFERENCES [dbo].[GameSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GamePlayerOnGame'
CREATE INDEX [IX_FK_GamePlayerOnGame]
ON [dbo].[PlayerOnGameSet]
    ([Game_Id]);
GO

-- Creating foreign key on [Publisher_Id] in table 'GameSet'
ALTER TABLE [dbo].[GameSet]
ADD CONSTRAINT [FK_PublisherGame]
    FOREIGN KEY ([Publisher_Id])
    REFERENCES [dbo].[PublisherSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PublisherGame'
CREATE INDEX [IX_FK_PublisherGame]
ON [dbo].[GameSet]
    ([Publisher_Id]);
GO

-- Creating foreign key on [TeamId] in table 'LaBaffGuildMasterSet'
ALTER TABLE [dbo].[LaBaffGuildMasterSet]
ADD CONSTRAINT [FK_LaBaffLaBaffGuildMaster]
    FOREIGN KEY ([TeamId])
    REFERENCES [dbo].[LaBaffSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [TeamId] in table 'LaBaffMemberSet'
ALTER TABLE [dbo].[LaBaffMemberSet]
ADD CONSTRAINT [FK_LaBaffLaBaffMember]
    FOREIGN KEY ([TeamId])
    REFERENCES [dbo].[LaBaffSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [PollAnswer_Id] in table 'PollUserSet'
ALTER TABLE [dbo].[PollUserSet]
ADD CONSTRAINT [FK_PollAnswerPollUser]
    FOREIGN KEY ([PollAnswer_Id])
    REFERENCES [dbo].[PollAnswerSet]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PollAnswerPollUser'
CREATE INDEX [IX_FK_PollAnswerPollUser]
ON [dbo].[PollUserSet]
    ([PollAnswer_Id]);
GO

-- Creating foreign key on [Poll_Id] in table 'PollAnswerSet'
ALTER TABLE [dbo].[PollAnswerSet]
ADD CONSTRAINT [FK_PollPollAnswer]
    FOREIGN KEY ([Poll_Id])
    REFERENCES [dbo].[PollSet]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PollPollAnswer'
CREATE INDEX [IX_FK_PollPollAnswer]
ON [dbo].[PollAnswerSet]
    ([Poll_Id]);
GO

-- Creating foreign key on [PrivateMessageBox_Id] in table 'PrivateMessageReadSet'
ALTER TABLE [dbo].[PrivateMessageReadSet]
ADD CONSTRAINT [FK_PrivateMessageBoxPrivateMessageRead]
    FOREIGN KEY ([PrivateMessageBox_Id])
    REFERENCES [dbo].[PrivateMessageBoxSet]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PrivateMessageBoxPrivateMessageRead'
CREATE INDEX [IX_FK_PrivateMessageBoxPrivateMessageRead]
ON [dbo].[PrivateMessageReadSet]
    ([PrivateMessageBox_Id]);
GO

-- Creating foreign key on [webpages_Roles_RoleId] in table 'ForumSecuritySet'
ALTER TABLE [dbo].[ForumSecuritySet]
ADD CONSTRAINT [FK_webpages_RolesForumSecurity]
    FOREIGN KEY ([webpages_Roles_RoleId])
    REFERENCES [dbo].[webpages_Roles]
        ([RoleId])
    ON DELETE CASCADE ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_webpages_RolesForumSecurity'
CREATE INDEX [IX_FK_webpages_RolesForumSecurity]
ON [dbo].[ForumSecuritySet]
    ([webpages_Roles_RoleId]);
GO

-- Creating foreign key on [VeteranStatus_Id] in table 'VeteranWall'
ALTER TABLE [dbo].[VeteranWall]
ADD CONSTRAINT [FK_VeteranStatusVeteranWall]
    FOREIGN KEY ([VeteranStatus_Id])
    REFERENCES [dbo].[VeteranStatus]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_VeteranStatusVeteranWall'
CREATE INDEX [IX_FK_VeteranStatusVeteranWall]
ON [dbo].[VeteranWall]
    ([VeteranStatus_Id]);
GO

-- Creating foreign key on [VeteranWallPeriodBegin_Id] in table 'VeteranWall'
ALTER TABLE [dbo].[VeteranWall]
ADD CONSTRAINT [FK_VeteranWallPeriodVeteranWall]
    FOREIGN KEY ([VeteranWallPeriodBegin_Id])
    REFERENCES [dbo].[VeteranWallPeriod]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_VeteranWallPeriodVeteranWall'
CREATE INDEX [IX_FK_VeteranWallPeriodVeteranWall]
ON [dbo].[VeteranWall]
    ([VeteranWallPeriodBegin_Id]);
GO

-- Creating foreign key on [VeteranWallPeriodEnd_Id] in table 'VeteranWall'
ALTER TABLE [dbo].[VeteranWall]
ADD CONSTRAINT [FK_VeteranWallPeriodVeteranWall1]
    FOREIGN KEY ([VeteranWallPeriodEnd_Id])
    REFERENCES [dbo].[VeteranWallPeriod]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_VeteranWallPeriodVeteranWall1'
CREATE INDEX [IX_FK_VeteranWallPeriodVeteranWall1]
ON [dbo].[VeteranWall]
    ([VeteranWallPeriodEnd_Id]);
GO

-- Creating foreign key on [webpages_Roles_RoleId] in table 'webpages_UsersInRoles'
ALTER TABLE [dbo].[webpages_UsersInRoles]
ADD CONSTRAINT [FK_webpages_UsersInRoles_webpages_Roles]
    FOREIGN KEY ([webpages_Roles_RoleId])
    REFERENCES [dbo].[webpages_Roles]
        ([RoleId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [UserProfile_UserId] in table 'webpages_UsersInRoles'
ALTER TABLE [dbo].[webpages_UsersInRoles]
ADD CONSTRAINT [FK_webpages_UsersInRoles_UserProfile]
    FOREIGN KEY ([UserProfile_UserId])
    REFERENCES [dbo].[UserProfile]
        ([UserId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_webpages_UsersInRoles_UserProfile'
CREATE INDEX [IX_FK_webpages_UsersInRoles_UserProfile]
ON [dbo].[webpages_UsersInRoles]
    ([UserProfile_UserId]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------